package model;

import java.util.Date;
import java.util.UUID;

/**
 * This class represents one case from the Business case. 
 * The Business case is composed by two or more cases, which are used for comparison to find which one is the best option to be invested on. 
 * @author D058585
 *
 */
public class Case implements Comparable<Case>
{
	private UUID ID;
	private String name;
	private String description;
	private String conclusion;
	private Date createdDate;
	private Date lastUpdated;
	
	public Case(String name)
	{
		this.name = name;
		ID = UUID.randomUUID();
		createdDate = new Date();
		lastUpdated = new Date();
	}
	
	public Case(UUID ID)
	{
		this.ID = ID;
		createdDate = new Date();
		lastUpdated = new Date();
	}
	
	/**
	 * Returns the name of the case
	 * @return Case name
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * Sets the name of the case to the String passed by the parameter
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * Returns the textual description of the case
	 * @return Case description
	 */
	public String getDescription() {
		if(description == null)
			description = "";
		return description;
	}
	
	/**
	 * Sets the case textual description
	 * @param description Case's description
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	
	/**
	 * Returns the textual conclusion of the case analysis
	 * @return Case conclusion
	 */
	public String getConclusion() {
		return conclusion;
	}
	
	/**
	 * Sets the textual conclusion of the case
	 * @param caseConclcusion Case conclusion
	 */
	public void setConclusion(String conclcusion) {
		this.conclusion = conclcusion;
	}
	
	/**
	 * Returns the ID for the current Case
	 * @return Case's ID
	 */
	public UUID getID() {
		return ID;
	}
	
	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Date getLastUpdated() {
		return lastUpdated;
	}

	public void setLastUpdated(Date lastUpdated) {
		this.lastUpdated = lastUpdated;
	}

	@Override
	public boolean equals(Object obj) 
	{
		boolean equals = false;
		
		if(obj != null)
			if(obj.getClass() == this.getClass())
				equals = (ID.equals(((Case)obj).getID()));
		
		return equals;
	}
	
	@Override
	public int hashCode() 
	{
		return ID.hashCode();
	}
	
	@Override
	public int compareTo(Case other) 
	{
		return name.compareToIgnoreCase(other.getName());
	}
}